<template>
  <el-container class="home-container">
    <!-- <el-aside class="el-aside" width="200px"> -->
    <el-menu
      router
      ref="menu"
      :class="['home-menu', isCollapse ? 'collapse-menu' : '']"
      :collapse="isCollapse"
      :collapse-transition="false"
    >
      <div class="logo">
        <i class="el-icon-reading"></i>
        <h3 v-show="!isCollapse">Manager</h3>
      </div>
      <el-menu-item index="/dashboard">
        <i class="el-icon-s-home"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu index="/user">
        <template slot="title">
          <i class="el-icon-s-custom"></i>
          <span>用户管理</span>
        </template>
        <el-menu-item index="/user">
          <span slot="title">用户列表</span>
        </el-menu-item>
        <el-menu-item>
          <span slot="title">添加用户</span>
        </el-menu-item>
        <el-menu-item>
          <span slot="title">修改用户</span>
        </el-menu-item>
      </el-submenu>

      <el-menu-item index="category">
        <i class="el-icon-menu"></i>
        <span slot="title">分类管理</span>
      </el-menu-item>
      <el-menu-item index="/post">
        <i class="el-icon-document"></i>
        <span slot="title">新增博客</span>
      </el-menu-item>
    </el-menu>
    <!-- </el-aside> -->
    <el-container>
      <el-header class="el-header">
        <i
          class="el-icon-s-fold"
          :class="isCollapse ? 'isCollapse' : ''"
          @click="isCollapse = !isCollapse"
        ></i>
      </el-header>
      <el-main class="el-main">
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: 'Home',
  data() {
    return {
      isCollapse: false,
    };
  },
  //生命周期
  mounted() {
    this.$refs['menu'].activeIndex = this.$route.path;
  },
  methods: {
    handleCollapse() {
      //切换状态
      this.isCollapse = !this.isCollapse;
    },
  },
};
</script>

<style>
.home-container {
  height: 100vh;
}
.el-aside {
  background-color: #fff;
}
.el-header {
  display: flex;
  align-items: center;
  background-color: #fff;
  font-size: 24px;
}
.el-header i {
  transition: 0.3s;
}
.el-main {
  background-color: rgb(252, 252, 252);
}
.logo {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  height: 60px;
  background-color: skyblue;
  font-size: 28px;
  color: white;
}
.isCollapse {
  transform: rotate(-180deg);
}
.home-menu {
  width: 200px;
  transition: width 3s;
}
.collapse-menu {
  width: 64px;
}
</style>
